/**
 * 
 */
package lt.ruta.ui;

import javax.microedition.lcdui.Alert;
import javax.microedition.lcdui.AlertType;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Displayable;

/**
 * @author Vincentas
 *
 */
public abstract class DialogForm extends Alert implements CommandListener {

	private static final Command yesCommand = new Command("Yes", Command.OK, 0);
	
	private static final Command cancelCommand = new Command("Cancel", Command.CANCEL, 1);
	
	public DialogForm(String title, String message) {
		super(title, message, null, AlertType.CONFIRMATION);
		setTimeout(FOREVER);
		
		addCommand(yesCommand);
		addCommand(cancelCommand);
		
		setCommandListener(this);
	}

	/* (non-Javadoc)
	 * @see javax.microedition.lcdui.CommandListener#commandAction(javax.microedition.lcdui.Command, javax.microedition.lcdui.Displayable)
	 */
	public void commandAction(Command command, Displayable displayable) {
		if (command.equals(yesCommand)) {
			onYes();
		} else {
			onCancel();
		}
	}
	
	public abstract void onYes();
	
	public abstract void onCancel();
}
